home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
echsys10.zip
/
ENVSYS.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-09-25
|
25KB
|
600 lines
; EnvSys : put current system data (drive, dir, time, date etc)
; into an environment variable named first on the command line
;
; Version 1.0
;
; Free Software by TapirSoft Gisbert W.Selke, Sept 1989
;
; The environment setting stuff is
; Copyright 1987, A. B. Krueger GPW MI 48236
; All rights reserved. Contact "ARNY KRUEGER"
; at the EXEC-PC BBS (414-964-5160) for permission
; to use commercially.
;
; Otherwise, this programme may be used and copied any way you wish, but don't
; sell it. Give credit where credit is due, please. - The copyright remains
; with me and Arny; I do not guarantee proper operation of this utility; the
; whole risk of use lies with the user.
;
; Usage: envsys <varname> <string>
; String is put into an environment variable named varname;
; two-char sequences introduced by '^' are replaced as indicated
; at 'Usage' below.
;
; TASM envsys or MASM envsys
; TLINK /t envsys LINK envsys
; EXEBIN envsys.exe envsys.com
BackSpace Equ 08h
LineFeed Equ 0Ah
Return Equ 0Dh
CtrlZ Equ 1Ah
StuffChar Macro Chr ; macro to put a character
Push ax
Mov al, Chr ; into the env string
Call StuffIt
Pop ax
Endm
Jmps Macro Label ; Jump short
Jmp short Label
Endm
cseg Segment para public
Extrn env_set:near,DirString:byte,TimeBuf:byte,DateBuf:byte
Extrn OutLine:byte,OurStack:byte,ProgEnd:byte
Org 0080h
Parameter Db ?
Org 100h
Assume cs:cseg, ds:cseg, es:cseg, ss:cseg
Start: Jmp Begin
db 'SPECIAL='
Special db '^'
db Return
Copyright db 'EnvSys 1.0 - Free software by TapirSoft'
db ' Gisbert W.Selke, Sept 89', Return, LineFeed
db 'Parts copyright 1987, A. B. Krueger GPW MI 48236. '
db Return, LineFeed
db 'Use at your own risk.$', BackSpace, ' '
db Return, LineFeed, CtrlZ
Usage1 db Return, LineFeed, LineFeed
db 'Usage: envsys <varname> <string>', Return, LineFeed
db 'The string is put into the named environment '
db 'variable', Return, LineFeed
db 'with "$'
Usage2 db '@" replaced as indicated by @:', Return, LineFeed
db ': drive; \ directory; F free disk space; '
db 'T total disk space; R free RAM;', Return, LineFeed
db 'r RAM size; l #drives; f #floppies; P #printers; '
db 'S #serial ports;', Return, Linefeed
db '7 coprocessor? L LPT1 status; V video mode; '
db 'w screen width; t type of PC;', Return, LineFeed
db 'v DOS version; b BIOS version; i "<" symbol; '
db 'o ">" symbol; p "|" symbol; ', Return, LineFeed
db 'O switch char; A author''s note; '
db 'x char given by next 2 hex digits;', Return, LineFeed
db 'K key typed by user; C country code; $'
Usage3 db ' currency string;', Return, LineFeed
db 'k 1000s separator; 1 decimal separator; '
db '/ date separator; - time separator;'
db Return, LineFeed
db 'D day; M month; Y year; W weekday; h hour; m minute; '
db 's second; c centisecond.'
db Return, LineFeed, Return, LineFeed, '$'
RetVal db 0
ModelString db '??80AP30??ATJRXTPC'
ModelStrLen Label Byte
CmdLetters db 'csmhWYMD-/1k$CpoiKxAObvtwVL7SPflRrTF\:';command letters
EndCmdLetters Label Word
; **NOTE**: order of CmdLetters and Dispatch is reversed w.r.t. each other!
Dispatch dw Drive, Directory, FreeSpace, TotalSpace, MemSize
dw FreeMem, LogicDrives, Floppies, Printers
dw CommPorts, Coproc, LptStat, VideoMode, VideoWidth
dw SysModel, DosVersion, BiosVersion, SwitchChar, Author
dw Hexnumber, KeyBoard
dw StdInSymbol, StdOutSymbol, PipeSymbol, CountryInfo
dw Currency, Thousands, Decimal, DateSep, TimeSep
dw Day, Month, Year, WeekDay
dw Hour, Minute, Second, CentiSecond
Begin: Mov sp, Offset OurStack ; point to our own stack
Mov ah, 2Ch ; get current time right now
Int 21h
Mov [TimeBuf], ch ; stow away
Mov [TimeBuf+1], cl
Mov [TimeBuf+2], dh
Mov [TimeBuf+3], dl
Mov ah, 2Ah ; get current date
Int 21h
Sub cx, 1900 ; remove centuries
Mov word ptr [DateBuf], cx ; stow away
Mov [DateBuf+2], dh
Mov [DateBuf+3], dl
Mov [DateBuf+4], al
Mov si, 1+offset Parameter ; command line string
Xor al, al
Mov [OutLine], al ; init environment line
FindName: Lodsb ; find first parameter,
Cmp al, Return ; i.e., name of env variable
Je ShowUsage
Cmp al, ' '
Je FindName
Cmp al, 09h
Je FindName
FindName2: Cmp al, Return ; stuff all its characters
Je EndName
Cmp al, ' '
Je EndName
Cmp al, 09h
Je EndName
Call StuffIt
Lodsb
Jmps FindName2
EndName: StuffChar '=' ; prepare to set it
Cmp al, Return
Je Done
; now parse command line proper
Cmp al, ' ' ; skip first char, if
Je NextChar ; blank or tab
Cmp al, 09h
Je NextChar
Cmp al, Return
Jne CheckSpecials
ShowUsage: Mov dx, offset Copyright ; show author's note
Mov ah, 09h
Int 21h
Mov dx, offset Usage1 ; show usage hints
Mov ah, 09h
Int 21h
Mov dl, [Special]
Mov ah, 02h
Int 21h
Mov dx, offset Usage2 ; more usage hints
Mov ah, 09h
Int 21h
Mov dl, '$'
Mov ah, 02h
Int 21h
Mov dx, offset Usage3 ; more usage hints
Mov ah, 09h
Int 21h
Mov ax, 4CFFh ; termination code
Int 21h
NextChar: Lodsb
Cmp al, Return ; are we done?
Jne CheckSpecials
Done: Mov si, offset OutLine ; point to env line
Call env_set ; set environment variable
Or [OutLine], 80h ; set high bit
Mov si, of